// 2025/4/19
// 最大子矩阵

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N, tmp; cin >> N;
    vector<int> row(N + 1, 0), col(N + 1, 0);
    vector<vector<int>> preMatrix(N + 1, vector<int>(N + 1, 0));
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            cin >> tmp;
            preMatrix[i][j] = row[i] + col[j] + preMatrix[i - 1][j - 1] + tmp;
            row[i] += tmp;
            col[j] += tmp;
        }
    }
    int ans = preMatrix[1][1];
    for(int i1 = 0; i1 < N; i1++)
    {
        for(int j1 = 0; j1 < N; j1++)
        {
            for(int i2 = i1 + 1; i2 <= N; i2++)
            {
                for(int j2 = j1 + 1; j2 <= N; j2++)
                {
                    int size = preMatrix[i2][j2] - preMatrix[i1][j2] - preMatrix[i2][j1] + preMatrix[i1][j1];
                    ans = max(ans, size);
                }
            }
        }
    }
    cout << ans << endl;
}
// 64 位输出请用 printf("%lld")